﻿using DA_AcquisitionCommon;
using DA_AcquisitionCommon.Enumeration;
using DA_AcquisitionEntity.Books;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DA_AcquisitionBLL.Books
{
    public class BiqukeBookBusiness
    {
        public string AcquisitionBookInfo(string url)
        {
           string docText = new Httphelp().HttpGet(url);
            var document = new HtmlDocument();
            document.LoadHtml(docText);
            Book_Info bookInfo = new Book_Info();
            bookInfo.BI_Name = document.DocumentNode.SelectSingleNode("//*[@id='info']/h1").InnerText;
            string author= document.DocumentNode.SelectSingleNode("//*[@id='info']/p[1]").InnerText;
            bookInfo.BI_Author = author.Substring(author.IndexOf(":") + 1);
            bookInfo.BI_Type = (int)BookType.Urban;
            string latestUpdateTime = document.DocumentNode.SelectSingleNode("//*[@id='info']/p[4]").InnerText;
            bookInfo.BI_LatestUpdateTime = Convert.ToDateTime(latestUpdateTime.Substring(latestUpdateTime.IndexOf("：") +1));
            bookInfo.BI_CreateTime = DateTime.Now;
            bookInfo.BI_UpdateTime = DateTime.Now;
            return "";
        }
    }
}
